class CreateComments < ActiveRecord::Migration
  def self.up
    create_table :comments do |t|
      t.text       :body
      t.boolean    :is_published, :default => false
      t.boolean    :is_unread, :default => false
      t.references :post
      t.integer    :author_id

      t.timestamps
    end

    add_foreign_key('comments', 'post_id',   'posts')
    add_foreign_key('comments', 'author_id', 'users')
  end

  def self.down
    remove_foreign_key('comments', 'posts')
    remove_foreign_key('comments', 'users')
    drop_table :comments
  end
end